import { goodslist } from "../../http/api";
import {$error} from "../../components/msg/msg"
const state={
    datalist:[]
}
// mutations来修改state
const mutations = {
    changegoodslist(state,datalist){
        console.log(datalist);
        state.datalist = datalist;
    }
}

const actions = {
    getgoodslistActions(context){
        // let that=this
        goodslist().then(res=>{
            // console.log(res);
            if (res.status == 201) {
                console.log(res);
                context.commit('changegoodslist',res.data)
              } else {
                $error(res.message);
                context.commit('changegoodslist',[])
                
              }
        })
        
    }

}
const getters = {
    datalist(state){
        return state.datalist
    }
}

export default{
    state,
    mutations,
    actions,
    getters,
    namespaced:true,//使用命名空间
}